﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Sinacor.Infra.ServiceAccess;
using Sample.WPF.Bmf.Calendario.Calendario;
using Sample.WPF.Bmf.Ordens.Ordem;

namespace Sample.WPF
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public List<DateTime> ResultadoConsultaCalendario
        {
            get { return (List<DateTime>)GetValue(ResultadoConsultaCalendarioProperty); }
            set { SetValue(ResultadoConsultaCalendarioProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ResultadoConsultaCalendario.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ResultadoConsultaCalendarioProperty =
            DependencyProperty.Register("ResultadoConsultaCalendario", typeof(List<DateTime>), typeof(Window1), new UIPropertyMetadata(null));



        public List<ConsultarNetGeralClienteResponse> ResultadoConsultaOrdens
        {
            get { return (List<ConsultarNetGeralClienteResponse>)GetValue(ResultadoConsultaOrdensProperty); }
            set { SetValue(ResultadoConsultaOrdensProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ResultadoConsultaOrdens.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ResultadoConsultaOrdensProperty =
            DependencyProperty.Register("ResultadoConsultaOrdens", typeof(List<ConsultarNetGeralClienteResponse>), typeof(Window1), new UIPropertyMetadata(null));



        
        public Window1()
        {
            InitializeComponent();
            this.DataContext = this;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            this.ResultadoConsultaCalendario = null;
            AuthenticationParm parm = new AuthenticationParm();
            parm.LoginName = "BMF03";
            parm.Password = "BMF03XX";
            parm.CompanyId = 21;

            using (ServiceClient<ICalendario> sc =
                new ServiceClient<ICalendario>(parm, "Tcp.Bmf.Calendario.Calendario.ICalendario",
                                                @"C:\Sinacor\Mais\Projetos\MAIN\Source\Infra_2.0_desenv\SDK\Sample.WPF\bin\Endpoints\Bmf.Calendario.config"))
            {

                ICalendario calendario = sc.CreateProxy();
                this.ResultadoConsultaCalendario = calendario.ConsultarDatasPregoes();
            }
        }

        private void button1_Click_1(object sender, RoutedEventArgs e)
        {
            this.ResultadoConsultaOrdens = null;
            //parâmetros de autenticação
            AuthenticationParm parm = new AuthenticationParm();
            parm.LoginName = "BMF03";
            parm.Password = "BMF03XX";
            parm.CompanyId = 21;

            using (ServiceClient<IOrdem> sc = new ServiceClient<IOrdem>(parm,
                "Tcp.Bmf.Ordens.Ordem.IOrdem",
                @"C:\Sinacor\Mais\Projetos\MAIN\Source\Infra_2.0_desenv\SDK\Sample.WPF\bin\Endpoints\Bmf.Ordens.config"))
            {
                IOrdem ordem = sc.CreateProxy();

                ConsultarNetGeralClienteRequest request = new ConsultarNetGeralClienteRequest();

                this.ResultadoConsultaOrdens = ordem.ConsultarOrdensNetGeralCliente(request);
            }
        }
    }
}
